modeling_platform_version=`cat cd/resourcepackage/modelingplatform/manualinstall/packages/config/package.yaml | egrep -o [0-9]+.[0-9]+.[0-9]+.[0-9]+ | head -n 1`
modeling_platform_zip="modeling_platform_version_$modeling_platform_version.zip"
if [ ! -f "$modeling_platform_zip" ]; then
    echo "$modeling_platform_zip不存在，进行下载"
    wget -N https://pkg.mingyuanyun.com/packages/platform/core-full/$modeling_platform_version/$modeling_platform_version.zip -O $modeling_platform_zip
fi
unzip -t $modeling_platform_zip
if [ $? -ne 0 ];then
    echo "$modeling_platform_zip损坏，删除后重新下载"
    rm -rf $modeling_platform_zip
    wget -N https://pkg.mingyuanyun.com/packages/platform/core-full/$modeling_platform_version/$modeling_platform_version.zip -O $modeling_platform_zip
    unzip -t $modeling_platform_zip
    if [ $? -ne 0 ];then
        echo "重新下载$modeling_platform_zip损坏，删除损坏文件并退出"
        rm -rf $modeling_platform_zip
        exit 1
    fi
fi
rm -rf platform/
mkdir -p platform/
unzip -o -d platform/ $modeling_platform_zip > /dev/null
cp -rf _metadata platform/src
cp -rf sql/* platform/mysql
mkdir -p platform/workflow/4022_gfyx/流程模板
cp -rf  cd/resourcepackage/modelingplatform/manualinstall/packages/config/platform/* platform/src
cp -rf _metadata/MysoftVersion.config platform/src

mip_version=`cat cd/resourcepackage/modelingplatform/manualinstall/packages/config/package.yaml | egrep -o [0-9]+.[0-9]+.[0-9]+.[0-9]+ | sed -n '2,2p'`
if [ ! -f "mip_$mip_version.zip" ]; then
    wget -N https://pkg.mingyuanyun.com/packages/mipclient/core-full/$mip_version/$mip_version.zip -O mip_$mip_version.zip
fi
rm -rf mipclient/
mkdir -p mipclient/
unzip -o -d mipclient/ mip_$mip_version.zip > /dev/null
cp -rf  mipclient/src/* platform/src

bmp_version=`cat cd/resourcepackage/modelingplatform/manualinstall/packages/config/package.yaml | egrep -o [0-9]+.[0-9]+.[0-9]+.[0-9]+ | tail -n 1`
if [ ! -f "bpm_$bmp_version.zip" ]; then
    wget -N https://pkg.mingyuanyun.com/packages/bpm-erp/core-full/$bmp_version/$bmp_version.zip -O bpm_$bmp_version.zip
fi
rm -rf bpm/
mkdir -p bpm/
unzip -o -d bpm/ bpm_$bmp_version.zip > /dev/null
cp -rf  bpm/src/* platform/src

cp -rf ci/modelingplatformdockerfile/Dockerfile platform/
